#include <iostream>
#include <zlib/eventsystem/I_EventSystem.h>
#include <unistd.h>

using namespace std;

extern EventProcessor eventProcessor;

int ET_TEST = ET_CALL;
off_t offset = 0;

class TestCont : public Continuation
{
public:
	TestCont()
	{
    number = 0;
		cout << "construct function" << endl;
		SET_HANDLER(&TestCont::mainHandler);
	}

	int mainHandler(int event, void *data)
	{
    number++;
		Event *e = (Event *)data;
		cout << "testing..." << endl;
    if(number > 100)
      e->cancle();
    else
		  e->schedule_every(1);
	}

  int number;
};


int main()
{
	TestCont *t = new TestCont;
	t->mutex = new_ProxyMutex();
	eventProcessor.start(10);
	//eventProcessor.schedule_imm(t);
	//eventProcessor.schedule_imm_signal(t);
	//eventProcessor.schedule_at(t, 10);
	eventProcessor.schedule_every(t, 1);
	//eventProcessor.schedule_every(t, -10);

	while(true)
	{
		sleep(10);
	}
	return 0;
}
